<template>
  <div>
    <el-form>
      <el-row :gutter="24">
        <el-col :span="8">
          <el-form-item label="PATH" required>
            <el-input
              v-model="spec.hostPath.path"
              clearable
              placeholder="eg: /data"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="Path on the Node" required>
            <el-select v-model="spec.hostPath.type">
              <el-option
                v-for="(h, index) in hostPathTypes"
                :key="index"
                :label="h.label"
                :value="h.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";

const { t } = useI18n();
// type Prop = {
//   spec?: any;
// };
// const props = withDefaults(defineProps<Prop>(), {});
// const emit = defineEmits(["update:spec"]);
const spec = defineModel<any>("spec");

const hostPath = ref({
  path: "",
  type: "DirectoryOrCreate"
});

const hostPathTypes = [
  {
    value: "DirectoryOrCreate",
    label: t("business.storage.DirectoryOrCreateLabel")
  },
  {
    value: "Directory",
    label: t("business.storage.DirectoryLabel")
  },
  {
    value: "FileOrCreate",
    label: t("business.storage.FileOrCreateLabel")
  },
  {
    value: "File",
    label: t("business.storage.FileLabel")
  },
  {
    value: "Socket",
    label: t("business.storage.SocketLabel")
  },
  {
    value: "CharDevice",
    label: t("business.storage.CharDeviceLabel")
  },
  {
    value: "BlockDevice",
    label: t("business.storage.BlockDeviceLabel")
  }
];

onMounted(() => {
  if (!spec.value.hostPath) {
    spec.value.hostPath = hostPath.value;
  }
});
</script>

<style scoped></style>
